{% extends "layout.html" %}

{% block title %}
    <title>V2EX › 创作新主题</title>
{% endblock %}

{% block head %}
<link rel="stylesheet" type="text/css" href="/static/css/codemirror.css">
<script type="text/javascript" src="/static/js/codemirror.js"></script>
<script type="text/javascript" src="/static/js/selectboxit.min.js"></script>
{% endblock %}

{% block boxies %}
<div class="sep20"></div>
<div class="box">
    <div class="cell">发帖提示</div>
    <div class="inner">
        <ul style="margin-top: 0px;">
            <li><span class="f13">主题标题</span><div class="sep10"></div>
            请在标题中描述内容要点。如果一件事情在标题的长度内就已经可以说清楚，那就没有必要写正文了。
            <div class="sep10"></div>
            </li>
            <li><div class="fr" style="margin-top: -5px; margin-right: 5px;"><img src="/static/img/markdown.png?v=e609e600d2c78b542591448c17415367" border="0" width="32"></div><span class="f13">正文</span><div class="sep10"></div>
            可以在正文中为你要发布的主题添加更多细节。V2EX 支持 <span style="font-family: Consolas, 'Panic Sans', mono"><a href="https://help.github.com/articles/github-flavored-markdown" target="_blank">GitHub Flavored Markdown</a></span> 文本标记语法。
            <div class="sep10"></div>
            在正式提交之前，你可以点击本页面左下角的“预览主题”来查看 Markdown 正文的实际渲染效果。
            <div class="sep10"></div>
            </li>
            <li><span class="f13">选择节点</span><div class="sep10"></div>
            在最后，请为你的主题选择一个节点。恰当的归类会让你发布的信息更加有用。
            <div class="sep10"></div>
            你可以在主题发布后 300 秒内，对标题或者正文进行编辑。同时，在 300 秒内，你可以重新为主题选择节点。
            </li>
        </ul>
    </div>
</div>
<div class="sep20"></div>
<div class="box">
<div class="cell">社区指导原则</div>
    <div class="inner">
        <ul style="margin-top: 0px;">
            <li><span class="f13">尊重原创</span><div class="sep10"></div>
            请不要在 V2EX 发布任何盗版下载链接，包括软件、音乐、电影等等。V2EX 是创意工作者的社区，我们尊重原创。
            <div class="sep10"></div>
            </li>
            <li><span class="f13">友好互助</span><div class="sep10"></div>
            保持对陌生人的友善。用知识去帮助别人。
            </li>
        </ul>
    </div>
</div>
{% endblock %}

{% block main %}
<div class="sep20"></div>
<div class="box" id="box">
    <div class="cell"><a href="/">V2EX</a> <span class="chevron">&nbsp;›&nbsp;</span> 创作新主题</div>
    <form method="post" action="/new" id="compose">

    <div class="cell"><div class="fr fade" id="title_remaining">120</div>
        主题标题
    </div>
    <div class="cell" style="padding: 0px; background-color: #fff;"><textarea class="msl" rows="1" maxlength="120" id="topic_title" name="title" autofocus="autofocus" placeholder="请输入主题标题，如果标题能够表达完整内容，则正文可以为空">{{ post.title }}</textarea></div>
    <div class="cell"><div class="fr fade" id="content_remaining">20000</div>
        正文
    </div>
    <div style="text-align: left; border-bottom: 1px solid #e2e2e2; font-size: 14px; line-height: 120%;"><textarea style="visibility: hidden;" maxlength="20000" id="editor" name="content">{{ post.content_source }}</textarea></div>
    <div class="cell">
        <select name="node_name" id="nodes" style="width: 300px; font-size: 14px; display: none;" data-placeholder="请选择一个节点">
            <option></option>

            <option value="2015">2015 / 2015</option>

            <option value="2016">2016 / 2016</option>

            <option value="2017">2017 / 2017</option>

            <option value="3ds">3DS / 3ds</option>

            <option value="3g">3G / 3g</option>

            <option value="4g">4G / 4g</option>

            <option value="4sq">foursquare / 4sq</option>

            <option value="accessory">配件 / accessory</option>

            <option value="acg">ACG / acg</option>

            <option value="aden">亚丁湾 / aden</option>

            <option value="adobe">Adobe / adobe</option>

            <option value="adsense">AdSense / adsense</option>

            <option value="afterdark">天黑以后 / afterdark</option>

            <option value="alexa">Alexa / alexa</option>

            <option value="alfred">Alfred / alfred</option>

            <option value="alipay">支付宝 / alipay</option>

            <option value="amazon">Amazon / amazon</option>

            <option value="android">Android / android</option>

            <option value="angularjs">AngularJS / angularjs</option>

            <option value="animal">动物 / animal</option>

            <option value="ansible">Ansible / ansible</option>

            <option value="apache">Apache / apache</option>

            <option value="api">API / api</option>

            <option value="apple">Apple / apple</option>

            <option value="appnet">App.net / appnet</option>

            <option value="appstore">App Store / appstore</option>

            <option value="arch">Arch / arch</option>

            <option value="arduino">Arduino / arduino</option>

            <option value="atom">Atom / atom</option>

            <option value="aws">Amazon Web Services / aws</option>

            <option value="azure">Windows Azure / azure</option>

            <option value="babel">Project Babel / babel</option>

            <option value="bash">Bash / bash</option>

            <option value="bb">宽带症候群 / bb</option>

            <option value="beijing">北京 / beijing</option>

            <option value="bf3">Battlefield 3 / bf3</option>

            <option value="bf4">Battlefield 4 / bf4</option>

            <option value="bfbc2">BFBC2 / bfbc2</option>

            <option value="bike">骑行 / bike</option>

            <option value="bitcoin">Bitcoin / bitcoin</option>

            <option value="blackberry">BlackBerry / blackberry</option>

            <option value="blogger">Blogger / blogger</option>

            <option value="bmw">BMW / bmw</option>

            <option value="boinc">BOINC / boinc</option>

            <option value="bong">bong / bong</option>

            <option value="browsers">浏览器 / browsers</option>

            <option value="btsync">BTSync / btsync</option>

            <option value="business">商业模式 / business</option>

            <option value="c">C/C++/Obj-C / c</option>

            <option value="california">California / california</option>

            <option value="car">汽车 / car</option>

            <option value="career">职场话题 / career</option>

            <option value="cdn">CDN / cdn</option>

            <option value="centos">CentOS / centos</option>

            <option value="changsha">长沙 / changsha</option>

            <option value="chengdu">成都 / chengdu</option>

            <option value="chongqing">重庆 / chongqing</option>

            <option value="chrome">Chrome / chrome</option>

            <option value="cloud">云计算 / cloud</option>

            <option value="coc">Clash of Clans / coc</option>

            <option value="cod">Call of Duty / cod</option>

            <option value="coding">Coding / coding</option>

            <option value="coffee">咖啡 / coffee</option>

            <option value="couchdb">CouchDB / couchdb</option>

            <option value="create">分享创造 / create</option>

            <option value="css">CSS / css</option>

            <option value="cv">求职 / cv</option>

            <option value="dalian">大连 / dalian</option>

            <option value="db">数据库 / db</option>

            <option value="deals">优惠信息 / deals</option>

            <option value="dell">Dell / dell</option>

            <option value="design">设计 / design</option>

            <option value="designer">设计师 / designer</option>

            <option value="devops">DevOps / devops</option>

            <option value="diablo3">Diablo III / diablo3</option>

            <option value="django">Django / django</option>

            <option value="dns">DNS / dns</option>

            <option value="docker">Docker / docker</option>

            <option value="dota">DotA / dota</option>

            <option value="dotnet">.NET / dotnet</option>

            <option value="draw">画画 / draw</option>

            <option value="dream">梦 / dream</option>

            <option value="dribbble">Dribbble / dribbble</option>

            <option value="dropbox">Dropbox / dropbox</option>

            <option value="duolingo">Duolingo / duolingo</option>

            <option value="dust514">DUST 514 / dust514</option>

            <option value="earphone">耳机 / earphone</option>

            <option value="editors">编辑器 / editors</option>

            <option value="edu">教育 / edu</option>

            <option value="eggpain">强迫症 / eggpain</option>

            <option value="elasticsearch">Elasticsearch / elasticsearch</option>

            <option value="emacs">Emacs / emacs</option>

            <option value="en">English / en</option>

            <option value="erlang">Erlang / erlang</option>

            <option value="eve">EVE / eve</option>

            <option value="evernote">Evernote / evernote</option>

            <option value="facebook">Facebook / facebook</option>

            <option value="fe">前端开发 / fe</option>

            <option value="fedora">Fedora / fedora</option>

            <option value="feedback">反馈 / feedback</option>

            <option value="feo">前端优化 / feo</option>

            <option value="ffmpeg">FFmpeg / ffmpeg</option>

            <option value="fir">fir.im / fir</option>

            <option value="firebase">Firebase / firebase</option>

            <option value="firefox">Firefox / firefox</option>

            <option value="fit">健康 / fit</option>

            <option value="fitbit">Fitbit / fitbit</option>

            <option value="fitness">健身 / fitness</option>

            <option value="flash">Flash / flash</option>

            <option value="flask">Flask / flask</option>

            <option value="freebsd">FreeBSD / freebsd</option>

            <option value="fuzhou">福州 / fuzhou</option>

            <option value="gae">Google App Engine / gae</option>

            <option value="gamedev">游戏开发 / gamedev</option>

            <option value="games">游戏 / games</option>

            <option value="gdg">GDG / gdg</option>

            <option value="ghost">Ghost / ghost</option>

            <option value="gis">地理信息系统 / gis</option>

            <option value="git">git / git</option>

            <option value="gitcafe">GitCafe / gitcafe</option>

            <option value="github">GitHub / github</option>

            <option value="gitlab">GitLab / gitlab</option>

            <option value="global">海外留学 / global</option>

            <option value="go">Go / go</option>

            <option value="goban">围棋 / goban</option>

            <option value="google">Google / google</option>

            <option value="gossip">业界八卦 / gossip</option>

            <option value="gt">Gran Turismo / gt</option>

            <option value="gta">Grand Theft Auto / gta</option>

            <option value="gtd">Getting Things Done / gtd</option>

            <option value="gts">全球工单系统 / gts</option>

            <option value="guangzhou">广州 / guangzhou</option>

            <option value="guide">使用指南 / guide</option>

            <option value="guitar">吉他 / guitar</option>

            <option value="gw2">Guild Wars 2 / gw2</option>

            <option value="hadoop">Hadoop / hadoop</option>

            <option value="hangzhou">杭州 / hangzhou</option>

            <option value="hardware">硬件 / hardware</option>

            <option value="haskell">Haskell / haskell</option>

            <option value="hearthstone">Hearthstone / hearthstone</option>

            <option value="heroku">Heroku / heroku</option>

            <option value="hexo">Hexo / hexo</option>

            <option value="hishim">他他 / hishim</option>

            <option value="hongkong">香港 / hongkong</option>

            <option value="hos">Heroes of the Storm / hos</option>

            <option value="however">然而并没有 / however</option>

            <option value="html">HTML / html</option>

            <option value="http">HTTP / http</option>

            <option value="iad">iAd / iad</option>

            <option value="iama">I Am A / iama</option>

            <option value="icloud">iCloud / icloud</option>

            <option value="icode">iCode / icode</option>

            <option value="ideas">奇思妙想 / ideas</option>

            <option value="idev">iDev / idev</option>

            <option value="ifttt">IFTTT / ifttt</option>

            <option value="igame">iGame / igame</option>

            <option value="ikea">宜家 / ikea</option>

            <option value="imac">iMac / imac</option>

            <option value="imarketing">iMarketing / imarketing</option>

            <option value="imperfect">这个世界不完美 / imperfect</option>

            <option value="inc">公司运营 / inc</option>

            <option value="inception">Inception / inception</option>

            <option value="ingress">Ingress / ingress</option>

            <option value="instagram">Instagram / instagram</option>

            <option value="internet">互联网 / internet</option>

            <option value="invest">投资 / invest</option>

            <option value="ios">iOS / ios</option>

            <option value="ipad">iPad / ipad</option>

            <option value="iphone">iPhone / iphone</option>

            <option value="ipod">iPod / ipod</option>

            <option value="itunes">iTunes / itunes</option>

            <option value="iwork">iWork / iwork</option>

            <option value="java">Java / java</option>

            <option value="jekyll">Jekyll / jekyll</option>

            <option value="jetbrains">JetBrains / jetbrains</option>

            <option value="jiankongbao">监控宝 / jiankongbao</option>

            <option value="jiong">囧 / jiong</option>

            <option value="jobs">酷工作 / jobs</option>

            <option value="jp">日本 / jp</option>

            <option value="jquery">jQuery / jquery</option>

            <option value="js">JavaScript / js</option>

            <option value="kindle">Kindle / kindle</option>

            <option value="kunming">昆明 / kunming</option>

            <option value="la">Los Angeles / la</option>

            <option value="laiwang">来往 / laiwang</option>

            <option value="lamy">Lamy / lamy</option>

            <option value="leancloud">LeanCloud / leancloud</option>

            <option value="lego">LEGO / lego</option>

            <option value="life">生活 / life</option>

            <option value="lifestyle">生活方式 / lifestyle</option>

            <option value="line">LINE / line</option>

            <option value="linux">Linux / linux</option>

            <option value="lisp">Lisp / lisp</option>

            <option value="livid">Livid / livid</option>

            <option value="lol">英雄联盟 / lol</option>

            <option value="lua">Lua / lua</option>

            <option value="macbook">MacBook / macbook</option>

            <option value="macmini">Mac mini / macmini</option>

            <option value="macos">macOS / macos</option>

            <option value="macpro">Mac Pro / macpro</option>

            <option value="mactype">MacType / mactype</option>

            <option value="markdown">Markdown / markdown</option>

            <option value="math">数学 / math</option>

            <option value="mba">MacBook Air / mba</option>

            <option value="mbp">MacBook Pro / mbp</option>

            <option value="mechanical">机械键盘 / mechanical</option>

            <option value="meet">创业组队 / meet</option>

            <option value="meizu">魅族 / meizu</option>

            <option value="meteor">Meteor / meteor</option>

            <option value="mgs">Metal Gear Solid / mgs</option>

            <option value="microsoft">微软 / microsoft</option>

            <option value="mileage">行程控 / mileage</option>

            <option value="minecraft">Minecraft / minecraft</option>

            <option value="miui">MIUI / miui</option>

            <option value="ml">机器学习 / ml</option>

            <option value="mmm">买买买 / mmm</option>

            <option value="mobileme">MobileMe / mobileme</option>

            <option value="mongodb">MongoDB / mongodb</option>

            <option value="movie">电影 / movie</option>

            <option value="muji">无印良品 / muji</option>

            <option value="mushroom">蘑菇 / mushroom</option>

            <option value="music">音乐 / music</option>

            <option value="mysql">MySQL / mysql</option>

            <option value="nanjing">南京 / nanjing</option>

            <option value="nas">NAS / nas</option>

            <option value="nba">NBA / nba</option>

            <option value="nexus">Nexus / nexus</option>

            <option value="nginx">NGINX / nginx</option>

            <option value="nlp">自然语言处理 / nlp</option>

            <option value="nodejs">Node.js / nodejs</option>

            <option value="nokia">Nokia / nokia</option>

            <option value="nosql">NoSQL / nosql</option>

            <option value="notes">Notes / notes</option>

            <option value="nvidia">NVIDIA / nvidia</option>

            <option value="nyc">New York / nyc</option>

            <option value="olivida">OLIVIDA / olivida</option>

            <option value="oneapm">OneAPM / oneapm</option>

            <option value="openshift">OpenShift / openshift</option>

            <option value="opensource">开源软件 / opensource</option>

            <option value="openstack">OpenStack / openstack</option>

            <option value="opera">Opera / opera</option>

            <option value="oracle">Oracle / oracle</option>

            <option value="otaku">宅 / otaku</option>

            <option value="overwatch">Overwatch / overwatch</option>

            <option value="paper">Paper / paper</option>

            <option value="path">Path / path</option>

            <option value="pay"> Pay / pay</option>

            <option value="paypal">PayPal / paypal</option>

            <option value="pet">宠物 / pet</option>

            <option value="photograph">摄影 / photograph</option>

            <option value="photoshop">Photoshop / photoshop</option>

            <option value="php">PHP / php</option>

            <option value="pi">Raspberry Pi / pi</option>

            <option value="picky">Project Picky / picky</option>

            <option value="pixel">Pixel / pixel</option>

            <option value="plant">植物 / plant</option>

            <option value="pm">产品经理茶话会 / pm</option>

            <option value="podcast">Podcast / podcast</option>

            <option value="pokemon">精灵宝可梦 / pokemon</option>

            <option value="pomodoro">番茄工作法 / pomodoro</option>

            <option value="portal">Portal series / portal</option>

            <option value="postgresql">PostgreSQL / postgresql</option>

            <option value="programmer">程序员 / programmer</option>

            <option value="programming">编程 / programming</option>

            <option value="promotions">推广 / promotions</option>

            <option value="pronunciation">发音 / pronunciation</option>

            <option value="ps3">PlayStation 3 / ps3</option>

            <option value="ps4">PlayStation 4 / ps4</option>

            <option value="psvita">PlayStation Vita / psvita</option>

            <option value="puppet">Puppet / puppet</option>

            <option value="python">Python / python</option>

            <option value="qingdao">青岛 / qingdao</option>

            <option value="qna">问与答 / qna</option>

            <option value="qt">Qt / qt</option>

            <option value="quora">Quora / quora</option>

            <option value="random">随想 / random</option>

            <option value="re">正则表达式 / re</option>

            <option value="react">React / react</option>

            <option value="reading">阅读 / reading</option>

            <option value="reddit">reddit / reddit</option>

            <option value="redis">Redis / redis</option>

            <option value="remodel">装修 / remodel</option>

            <option value="riak">Riak / riak</option>

            <option value="ripple">Ripple / ripple</option>

            <option value="ror">Ruby on Rails / ror</option>

            <option value="router">路由器 / router</option>

            <option value="ruby">Ruby / ruby</option>

            <option value="running">跑步 / running</option>

            <option value="rustlang">Rust / rustlang</option>

            <option value="safari">Safari / safari</option>

            <option value="sanfrancisco">San Francisco / sanfrancisco</option>

            <option value="sc2">StarCraft 2 / sc2</option>

            <option value="scala">Scala / scala</option>

            <option value="scifi">科幻 / scifi</option>

            <option value="security">信息安全 / security</option>

            <option value="seo">搜索引擎优化 / seo</option>

            <option value="server">服务器 / server</option>

            <option value="shanghai">上海 / shanghai</option>

            <option value="share">分享发现 / share</option>

            <option value="shenzhen">深圳 / shenzhen</option>

            <option value="show">晒晒更健康 / show</option>

            <option value="simcity">SimCity / simcity</option>

            <option value="simracing">模拟驾驶 / simracing</option>

            <option value="sketch">Sketch / sketch</option>

            <option value="skyrim">上古卷轴 V / skyrim</option>

            <option value="smartisan">锤子手机 / smartisan</option>

            <option value="smartisanos">Smartisan OS / smartisanos</option>

            <option value="smartos">SmartOS / smartos</option>

            <option value="soccer">绿茵场 / soccer</option>

            <option value="software">软件 / software</option>

            <option value="soho">SOHO / soho</option>

            <option value="sony">SONY / sony</option>

            <option value="soylent">Soylent / soylent</option>

            <option value="ssd">SSD / ssd</option>

            <option value="ssh">SSH / ssh</option>

            <option value="ssl">SSL / ssl</option>

            <option value="starter">创造者 / starter</option>

            <option value="steam">Steam / steam</option>

            <option value="stormwind">Project Stormwind / stormwind</option>

            <option value="stripe">Stripe / stripe</option>

            <option value="sublime">Sublime Text / sublime</option>

            <option value="surface">Surface / surface</option>

            <option value="suzhou">苏州 / suzhou</option>

            <option value="swift">Swift / swift</option>

            <option value="tangcha">唐茶 / tangcha</option>

            <option value="taobao">淘宝 / taobao</option>

            <option value="taste">美酒与美食 / taste</option>

            <option value="tech">科技 / tech</option>

            <option value="ted">TED / ted</option>

            <option value="telegram">Telegram / telegram</option>

            <option value="textmate">TextMate / textmate</option>

            <option value="thinkpad">ThinkPad / thinkpad</option>

            <option value="tianjin">天津 / tianjin</option>

            <option value="tmux">tmux / tmux</option>

            <option value="tornado">Tornado / tornado</option>

            <option value="travel">旅行 / travel</option>

            <option value="trello">Trello / trello</option>

            <option value="tv">剧集 / tv</option>

            <option value="twitter">Twitter / twitter</option>

            <option value="typography">字体排印 / typography</option>

            <option value="u">大学 / u</option>

            <option value="uber">Uber / uber</option>

            <option value="ubuntu">Ubuntu / ubuntu</option>

            <option value="udacity">Udacity / udacity</option>

            <option value="udk">Unreal Development Kit / udk</option>

            <option value="uniqlo">UNIQLO / uniqlo</option>

            <option value="unity">UNITY / unity</option>

            <option value="us">美国 / us</option>

            <option value="v2ex">V2EX / v2ex</option>

            <option value="vagrant">Vagrant / vagrant</option>

            <option value="varnish">Varnish / varnish</option>

            <option value="velocity">Velocity / velocity</option>

            <option value="vim">Vim / vim</option>

            <option value="virtualbox">VirtualBox / virtualbox</option>

            <option value="visa">签证 / visa</option>

            <option value="vmware">VMware / vmware</option>

            <option value="vr">虚拟现实 / vr</option>

            <option value="vscode">Visual Studio Code / vscode</option>

            <option value="vue">Vue.js / vue</option>

            <option value="watch"> WATCH / watch</option>

            <option value="webmaster">站长 / webmaster</option>

            <option value="webos">webOS / webos</option>

            <option value="webrtc">WebRTC / webrtc</option>

            <option value="wechat">微信 / wechat</option>

            <option value="weibo">微博 / weibo</option>

            <option value="wii">Wii / wii</option>

            <option value="wikipedia">Wikipedia / wikipedia</option>

            <option value="windows">Windows / windows</option>

            <option value="wordpress">WordPress / wordpress</option>

            <option value="wow">World of Warcraft / wow</option>

            <option value="wp">Windows Phone / wp</option>

            <option value="writing">文学 / writing</option>

            <option value="wuhan">武汉 / wuhan</option>

            <option value="wwdc">WWDC / wwdc</option>

            <option value="x">翻译 / x</option>

            <option value="xbox360">Xbox 360 / xbox360</option>

            <option value="xboxone">Xbox One / xboxone</option>

            <option value="xcode">Xcode / xcode</option>

            <option value="xiamen">厦门 / xiamen</option>

            <option value="xian">西安 / xian</option>

            <option value="xiaomi">小米 / xiaomi</option>

            <option value="youtube">YouTube / youtube</option>

            <option value="zh2">中二病 / zh2</option>

            <option value="zhengzhou">郑州 / zhengzhou</option>

            <option value="zhihu">知乎 / zhihu</option>

        </select>
    </div>
    <div class="cell">
    最热节点 &nbsp; <a href="javascript:chooseNode('qna')" class="node">问与答</a> &nbsp;<a href="javascript:chooseNode('share')" class="node">分享发现</a> &nbsp;<a href="javascript:chooseNode('jobs')" class="node">酷工作</a> &nbsp;<a href="javascript:chooseNode('programmer')" class="node">程序员</a> &nbsp;<a href="javascript:chooseNode('macos')" class="node">macOS</a> &nbsp;<a href="javascript:chooseNode('create')" class="node">分享创造</a> &nbsp;<a href="javascript:chooseNode('python')" class="node">Python</a> &nbsp;<a href="javascript:chooseNode('iphone')" class="node">iPhone</a> &nbsp;<a href="javascript:chooseNode('android')" class="node">Android</a> &nbsp;<a href="javascript:chooseNode('apple')" class="node">Apple</a> &nbsp;<a href="javascript:chooseNode('linux')" class="node">Linux</a> &nbsp;<a href="javascript:chooseNode('idev')" class="node">iDev</a> &nbsp;<a href="javascript:chooseNode('mbp')" class="node">MacBook Pro</a> &nbsp;
    </div>
    <input type="hidden" name="content" value="" id="topic_content">
    <input type="hidden" name="once" value="13764">
    </form>
    <div class="cell"><div class="fr"><span id="error_message">{{ error['title'] }} {{ error['content'] }}</span> &nbsp; <button type="button" class="super normal button" onclick="publishTopic();"><li class="fa fa-paper-plane"></li> &nbsp;发布主题</button></div>
        <button class="super normal button" onclick="previewTopic();"><li class="fa fa-eye"></li> &nbsp;预览主题</button>
    </div>
</div>
{% endblock %}

{% block script %}
<script type="text/javascript">
var editor;
var memberId = 156;
    // var node = $("#editor");

$(document).ready(function() {

    $("#nodes").select2();

    editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
        mode: "markdown",
        lineNumbers: true,
        lineWrapping: true,
        indentUnit: 4
    });

    loadComposeDraft(memberId);

    editor.on('change', function(cm, change) {
        var text = cm.getValue();
        var max = 20000;
        var remaining = max - text.length;
        var r = $("#content_remaining");
        r.html(remaining);
        saveComposeDraft(memberId);
    });

    $("#topic_title").keyup(function(e) {
        var s = $("#topic_title");
        var text = s.val()
        var max = 120;
        var remaining = max - text.length;
        var r = $("#title_remaining");
        r.html(remaining);
        saveComposeDraft(memberId);
    });

    function chooseNode(node) {
        $("#nodes").select2("val", node);
        saveComposeDraft(memberId);
    }

})
</script>
{% endblock %}
